package com.douqu.game.core.controller;

import com.douqu.game.core.e.E_PlayerStatus;
import com.douqu.game.core.entity.battle.SpriteBattleTmp;
import com.douqu.game.core.container.PlayerContainer;
import com.douqu.game.core.entity.sprite.Sprite;

import java.io.Serializable;

/**
* Created by bean on 2017/7/25.
*/
public abstract class SpriteController implements Serializable {

    protected static final long serialVersionUID = 1L;

    /**
     * 父容器
     */
    private PlayerContainer playerContainer;


    private SpriteBattleTmp attachment;

    /**
     * 当前状态
     */
    protected E_PlayerStatus status;


//    public SpriteController()
//    {
//
//    }

    public void sendMsg(int code, byte[] data)
    {

    }

    /**
     * 是否在战斗中
     * @return
     */
    public boolean isBattling()
    {
        return status == E_PlayerStatus.BATTLING || status == E_PlayerStatus.BATTLE_WAIT_START || status == E_PlayerStatus.MATCH_WAIT_BATTLE;
//        return playerContainer != null && playerContainer instanceof BattleParentController;
    }

    public boolean isFree()
    {
        return status == E_PlayerStatus.FREE || status == E_PlayerStatus.MATCHING;
    }

    public void clearBattle()
    {
        setAttachment(null);
        setParent(null);
        setStatus(E_PlayerStatus.FREE);
    }




    public String getObjectIndex()
    {
        return "";
    }

    public String getName()
    {
        return "";
    }

    public boolean isPlayer()
    {
        return false;
    }


    public void setParent(PlayerContainer playerContainer)
    {
        this.playerContainer = playerContainer;
    }

    public SpriteBattleTmp getAttachment()
    {
        return attachment;
    }
    public void setAttachment(SpriteBattleTmp attachment)
    {
        this.attachment = attachment;
    }
    public PlayerContainer getParent()
    {
        return playerContainer;
    }

    public E_PlayerStatus getStatus() {
        return status;
    }

    public void setStatus(E_PlayerStatus status) {
        this.status = status;
    }


    @Override
    public String toString() {
        return "SpriteController{" +
                "playerContainer=" + playerContainer +
                ", attachment=" + attachment +
                '}';
    }
}
